
import contentHtml from './index.html'
import list from '../../mock/data.json'
import './index.css'

export default{
    data(){
        return{
            list:list,
            defaultActive:0
        }
    },
    template:contentHtml,
    methods:{
        changeActive(index){
            this.defaultActive = index

            // 楼层无动画版 (需要滚动到顶部位置的div当前所距离顶部的距离 | 当前出现滚动条的元素)
            let rightDom = document.getElementById('right')
            let height = document.getElementById('unit'+index).offsetTop;
            if(rightDom.scrollTop+30<height){
                setTimeout(()=>{
                    rightDom.scrollTop+=30
                    this.changeActive(index)
                },50)
                
            }
            else if(rightDom.scrollTop-30>height){
                setTimeout(()=>{
                    rightDom.scrollTop-=30
                    this.changeActive(index)
                },50)
            }
            else{
                rightDom.scrollTop = height
            }
           
        }
    }
   
}